package com.caregiver.watch.business.care.model.vo;

import com.caregiver.watch.business.data.model.po.HealthBaseData;
import com.caregiver.watch.business.user.model.vo.UserHealthGoalVo;
import com.caregiver.watch.common.constant.NumberConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

import static com.caregiver.watch.common.constant.NumberConstants.TEN_THOUSAND;
import static com.caregiver.watch.common.constant.NumberConstants.THIRTY;
import static com.caregiver.watch.common.constant.NumberConstants.THREE_HUNDRED;
import static com.caregiver.watch.common.constant.NumberConstants.TWELVE;
import static com.caregiver.watch.common.constant.NumberConstants.ZERO;


/**
 * @Description: 用户当天的运动数据
 * @Author 疆戟
 * @Date 2025/9/20 11:08
 * @Version 1.0
 */
@Data
@Schema(description = "用户当天的运动数据")
public class TodaySportDataVo {


    @Schema(description = "运动时长")
    private Integer runTime;
    // 运动目标
    @Schema(description = "运动目标")
    private Integer runTarget;
    /**
     * 消耗的卡路里
     */
    @Schema(description = "消耗的卡路里")
    private BigDecimal totalCalorie;

    @Schema(description = "每日消耗目标")
    private Integer dailyCalorieTarget;

    @Schema(description = "步数")
    private Integer totalStep;

    @Schema(description = "每日步数目标")
    private Integer dailyStepTarget;

    @Schema(description = "站立时长")
    private Integer standTime;

    @Schema(description = "每日站立时长目标")
    private Integer dailyStandTimeTarget;

    public TodaySportDataVo() {
        this.runTime = ZERO;
        this.runTarget = THIRTY;
        this.totalCalorie = BigDecimal.ZERO;
        this.dailyCalorieTarget = THREE_HUNDRED;
        this.totalStep = ZERO;
        this.dailyStepTarget = TEN_THOUSAND;
        this.standTime = ZERO;
        this.dailyStandTimeTarget = TWELVE;
    }


    public static TodaySportDataVo build(HealthBaseData healthBaseData, UserHealthGoalVo userHealthGoalVo) {
        TodaySportDataVo todaySportDataVo = new TodaySportDataVo();
        if (Objects.isNull(healthBaseData)) {
            return todaySportDataVo;
        }
        todaySportDataVo.setRunTime(healthBaseData.getActivityDuration());
        todaySportDataVo.setTotalCalorie(healthBaseData.getCalorie());
        todaySportDataVo.setTotalStep(healthBaseData.getStepCount());
        todaySportDataVo.setStandTime(healthBaseData.getStandTime());
        if (Objects.nonNull(userHealthGoalVo)) {
            todaySportDataVo.setRunTarget(userHealthGoalVo.getDailyActivityDuration());
            todaySportDataVo.setDailyCalorieTarget(userHealthGoalVo.getDailyActivityConsumption());
            todaySportDataVo.setDailyStepTarget(userHealthGoalVo.getDailySteps());
            todaySportDataVo.setDailyStandTimeTarget(userHealthGoalVo.getDailyStandingCount());
        }
        return todaySportDataVo;
    }
}
